package hy.config;

import hy.beans.Dog;
import hy.beans.Person;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyCfg2 {
    //@Bean
    Dog getD(){
        return new Dog();
    }

    @ConditionalOnBean(name="getD")//容器中存在getD这个bean就把getP这个bean注入到容器中
    @Bean
    Person getP(){
        Person p=new Person();
        //p.d=getD();
        return p;
    }
}